﻿using System;
using System.Windows.Media.Imaging;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using PPP.Model;
using PPP.ViewModel.BaseModel;

namespace PPP.ViewModel.WindowModel {
    /// <summary>
    /// ViewModel for a picture properties. 
    /// 
    /// <list type="bullet">
    /// <item>
    /// <term>Author</term>
    /// <description>Sebastian Will</description>
    /// </item>
    /// </list>
    /// 
    /// </summary>
    public class PropertiesViewModel : ToolViewModel {
              
        #region Fields

        /// <summary>
        /// The selected picture.
        /// </summary>
        private PicturePropertiesViewModel _selectedPicture = null;

        #endregion

	    #region Consts

        /// <summary>
        /// The dockable content content id.
        /// </summary>
        public const string ToolContentId = "PropertiesTool";

        #region PropertyName Consts

        /// <summary>
        /// The <see cref="SelectedPicture" /> property's name.
        /// </summary>
        public const string SelectedPicturePropertyName = "SelectedPicture";

        #endregion
	    #endregion

        #region Properties

        /// <summary>
        /// Gets the SelectedPicture property.
        /// Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public PicturePropertiesViewModel SelectedPicture {
            get {
                return _selectedPicture;
            }
            set {
                if (_selectedPicture == value)
                    return;

                _selectedPicture = value;
                RaisePropertyChanged(SelectedPicturePropertyName);

            }
        }

        #region Commands
        #endregion
        #endregion

        #region Constructors
                   
        /// <summary>
        /// Initializes a new instance of the PropertiesViewModel class.
        /// </summary>        
        public PropertiesViewModel()
            : base(Properties.ResourcesPaneTitle.PicturePropertiesPane) {
            //MainViewModel.This.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
            ContentId = ToolContentId;

            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri("pack://application:,,,/PPP;component/icons/gui/pictureProperties.png");                        
            bi.EndInit();
            IconSource = bi;

            Messenger.Default.Register<PropertyChangedMessage<PicturePropertiesViewModel>>(
                this,
                message => {
                    SelectedPicture = null;
                    SelectedPicture = message.NewValue;
                });
        }

        #endregion

        #region Methods
        #endregion

        #region Events
        #endregion


    }
}